﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Licenta1;

namespace Licenta1.Expressions
{
    [Serializable]
    class NumberExpression : Expression
    {
        double val;

        public NumberExpression(Context con, String strVal)
            : base(con)
        {
            try
            {
                if (strVal.Contains('.'))
                    strVal = strVal.Replace('.', ',');
                this.val = Convert.ToDouble(strVal);
            }
            catch (InvalidCastException)
            {
                this.val = 0;
            }
        }

        public NumberExpression(double val)
        {
            this.val = val;
        }

        public override object Value
        {
            get { return val; }
        }
    }
}